package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.YyClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.YyRoomMapper;
import com.ruoyi.system.domain.YyRoom;
import com.ruoyi.system.service.IYyRoomService;
import com.ruoyi.common.core.text.Convert;

/**
 * 宿舍Service业务层处理
 *
 * @author ruoyi
 * @date 2024-03-12
 */
@Service
public class YyRoomServiceImpl implements IYyRoomService
{
    @Autowired
    private YyRoomMapper yyRoomMapper;

    /**
     * 查询宿舍
     *
     * @param id 宿舍主键
     * @return 宿舍
     */
    @Override
    public YyRoom selectYyRoomById(Long id)
    {
        return yyRoomMapper.selectYyRoomById(id);
    }

    @Override
    public List<YyRoom> selectYyRoomByIdList(Long id) {
        List<YyRoom> yyRoomByIdList = yyRoomMapper.selectYyRoomByIdList(id);
        List<YyRoom> yyRoomListAll = yyRoomMapper.listAll();
        for (YyRoom yyRoomAll : yyRoomListAll)
        {
            for (YyRoom YyRoomById : yyRoomByIdList)
            {
                if (YyRoomById.getId().longValue() == yyRoomAll.getId().longValue())
                {
                    yyRoomAll.setFlag(true);
                    break;
                }
            }
        }
        return yyRoomListAll;
    }

    /**
     * 查询宿舍列表
     *
     * @param yyRoom 宿舍
     * @return 宿舍
     */
    @Override
    public List<YyRoom> selectYyRoomList(YyRoom yyRoom)
    {
        return yyRoomMapper.selectYyRoomList(yyRoom);
    }

    /**
     * 新增宿舍
     *
     * @param yyRoom 宿舍
     * @return 结果
     */
    @Override
    public int insertYyRoom(YyRoom yyRoom)
    {
        return yyRoomMapper.insertYyRoom(yyRoom);
    }

    /**
     * 修改宿舍
     *
     * @param yyRoom 宿舍
     * @return 结果
     */
    @Override
    public int updateYyRoom(YyRoom yyRoom)
    {
        return yyRoomMapper.updateYyRoom(yyRoom);
    }

    /**
     * 批量删除宿舍
     *
     * @param ids 需要删除的宿舍主键
     * @return 结果
     */
    @Override
    public int deleteYyRoomByIds(String ids)
    {
        return yyRoomMapper.deleteYyRoomByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除宿舍信息
     *
     * @param id 宿舍主键
     * @return 结果
     */
    @Override
    public int deleteYyRoomById(Long id)
    {
        return yyRoomMapper.deleteYyRoomById(id);
    }

    @Override
    public List<YyRoom> listAll() {
        return yyRoomMapper.listAll();
    }
}
